/**
 * 创建权限DTO
 * 作者：GodMainCode
 * 创建时间：2024-01-17
 * 修改时间：2024-01-17
 * 修改人：GodMainCode
 */

import { IsString, IsInt, IsOptional, Min, IsEnum } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { PermissionType } from '../../../interfaces/permission.interface';

export class CreatePermissionDto {
  @ApiProperty({ description: '权限名称', example: '查看用户列表' })
  @IsString()
  name: string;

  @ApiProperty({ description: '权限标识', example: 'user:list' })
  @IsString()
  code: string;

  @ApiProperty({ 
    description: '权限类型：1-目录 2-菜单 3-按钮',
    enum: PermissionType,
    default: PermissionType.MENU,
    example: PermissionType.MENU
  })
  @IsEnum(PermissionType)
  type: PermissionType;

  @ApiProperty({ description: '图标', required: false, example: 'user' })
  @IsString()
  @IsOptional()
  icon?: string;

  @ApiProperty({ description: '路由路径', required: false, example: '/user' })
  @IsString()
  @IsOptional()
  path?: string;

  @ApiProperty({ description: '组件路径', required: false, example: '/views/user/index' })
  @IsString()
  @IsOptional()
  component?: string;

  @ApiProperty({ description: '父级ID', required: false, example: 1 })
  @IsInt()
  @IsOptional()
  parent_id?: number;

  @ApiProperty({ description: '权限描述', required: false, example: '查看用户列表权限' })
  @IsString()
  @IsOptional()
  description?: string;

  @ApiProperty({ description: '排序', required: false, default: 0, example: 1 })
  @IsInt()
  @Min(0)
  @IsOptional()
  sort?: number;
} 